package leetcode

class Solution_242 {
    fun isAnagram(s: String, t: String): Boolean {
        val table = IntArray(256)
        for (c in s) {
            table[c.code] ++
        }
        for (c in t){
            table[c.code] --
            if (table[c.code] < 0) return false
        }
        for (i in table) {
            if (i != 0) return false
        }
        return true
    }
}

fun main() {
    println(Solution_242().isAnagram(s = "anagram", t = "nagaram") == true)
    println(Solution_242().isAnagram(s = "rat", t = "car") == false)
}